<template>
  <div class="history_hot">
    <section>
      <div class="title">
        <h3>历史记录</h3>
        <van-icon name="delete-o" @click="delFn" />
      </div>
      <div class="tags">
        <van-tag
          plain
          type="default"
          v-for="(item, index) in historyKeywordList"
          :key="index"
          @click="goToSearch(item)"
          >{{ item }}</van-tag
        >
      </div>
    </section>
    <section>
      <div class="title">
        <h3>热门搜索</h3>
      </div>
      <div class="tags">
        <van-tag
          plain
          v-for="(item, index) in hotKeywordList"
          :key="index"
          size="large"
          @click="goToSearch(item)"
          :type="item.is_hot == 1 ? 'danger' : 'default'"
          >{{ item }}</van-tag
        >
      </div>
    </section>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["historyKeywordList", "hotKeywordList"],
  methods: {
    goToSearch(item) {
      // 子传父
      this.$emit("goToSearch", item);
    },
    // 清除历史记录
    delFn() {
      this.historyKeywordList = []
    },
  },
  mounted() {
  }
};
</script>

<style lang = "less" scoped>
.history_hot {
  section {
    padding: 10px;
    background: #fff;
    margin-bottom: 20px;
    .title {
      display: flex;
      justify-content: space-between;
      font-size: 18px;
      margin-bottom: 10px;
    }
    .tags {
      text-align: left;
      .van-tag {
        font-size: 15px;
        margin-right: 10px;
        margin-bottom: 10px;
      }
    }
  }
}
</style>